// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import axios from 'axios';
import NProgress from 'nprogress';
import { Field, Cell } from 'mint-ui';
import 'mint-ui/lib/style.css';
import 'element-ui/lib/theme-default/index.css'
import App from './App';
import router from './router';
import store from './vuex/store';
import * as Url from './config/url';

Vue.use(Field);
Vue.use(Cell);

Vue.config.productionTip = false;
Vue.prototype.$http = axios;
Vue.prototype.$url = Url;

axios.interceptors.request.use((config) => {
  NProgress.inc(0.2);
  return config;
}, (error) => {
  NProgress.done();
  return Promise.reject(error);
});
axios.interceptors.response.use((response) => {
  NProgress.done();
  return response;
}, (error) => {
  NProgress.done();
  return Promise.reject(error);
});
router.beforeEach((to, from, next) => {
  NProgress.start();
  next();
});
router.afterEach(() => {
  NProgress.done();
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App },
});
